﻿using Sai.Core;
using Sai.Test.XUnit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;

namespace Sai.Test
{
    public class ChurnCalculatorFacts
    {
        public class TheCalculateMethod
        {
            [Fact, InMemoryTest]
            public void No_Changes_Reports_Zero_Churn()
            {
                const int totalClasses = 55;
                const int removedClasses = 0;
                const int addedClasses = 0;
                const int changedClasses = 0;

                ChurnCalculator c = new ChurnCalculator(totalClasses, removedClasses, addedClasses, changedClasses);

                Assert.Equal(0, c.Calculate());
            }


            [Fact, InMemoryTest]
            public void No_Changes_No_Classes_Reports_Zero_Churn()
            {
                const int totalClasses = 0;
                const int removedClasses = 0;
                const int addedClasses = 0;
                const int changedClasses = 0;

                ChurnCalculator c = new ChurnCalculator(totalClasses, removedClasses, addedClasses, changedClasses);

                Assert.Equal(0, c.Calculate());
            }

            [Fact, InMemoryTest]
            public void Total_Changes_Reports_100_Percent_Churn()
            {
                const int totalClasses = 110;
                const int removedClasses = 55;
                const int addedClasses = 55;
                const int changedClasses = 0;

                ChurnCalculator c = new ChurnCalculator(totalClasses, removedClasses, addedClasses, changedClasses);

                Assert.Equal(100, c.Calculate());
            }

            [Fact, InMemoryTest]
            public void Partial_Change_Reports_Percent_Churn()
            {
                const int totalClasses = 31;
                const int removedClasses = 1;
                const int addedClasses = 2;
                const int changedClasses = 3;

                ChurnCalculator c = new ChurnCalculator(totalClasses, removedClasses, addedClasses, changedClasses);

                Assert.Equal(29, c.Calculate());
            }

        }
    }
}
